checklogin();
function passopen(){

	document.getElementById("eyeopen").style.display="block";
	document.getElementById("eyeclose").style.display="none";
	document.getElementById("pass").type="text";
}

function passclose(){

	document.getElementById("eyeopen").style.display="none";
	document.getElementById("eyeclose").style.display="block";
	document.getElementById("pass").type="password";
}

function inppass(){
	var pass =document.getElementById("pass").value;
	if(pass===""){
		document.getElementById("passclean").style.display="none";
	}else{
		document.getElementById("passclean").style.display="block";	
	}
}

document.getElementById("passclean").onclick=function(){
	document.getElementById("pass").value="";
	document.getElementById("passclean").style.display="none";
}

function inpaccount(){
	var pass =document.getElementById("account").value;
	if(pass===""){
		document.getElementById("accountclean").style.display="none";
	}else{
		document.getElementById("accountclean").style.display="block";	
	}
}

document.getElementById("accountclean").onclick=function(){
	document.getElementById("account").value="";
	document.getElementById("accountclean").style.display="none";
}

function loginbt(){
	var account = document.getElementById("account").value;
	var pass =document.getElementById("pass").value;
	$.ajax({
		url:"login",
		type:"post",
		async:true,
		dataType:"json",
		data:{account,pass},
		success:function (data){
			if(data.account==="BU"){
				alert("跳转商户");
			}else if(data.account==="GR"){
				alert("工人");
			}else{
				alert("账户密码错误");
			}

		},
		error:function (data){
			alert("请求失败");
		}
	})
}

function checklogin(){
	$.ajax({
		url:"checklogin",
		type:"post",
		dataType:"json",
		async: true,
		data:{},
		success:function (data){
			//请求成功填入账号
			var accou =document.getElementById("account");
			if (data.inf==="已存在"){
				accou.value=data.account;
			}
		},
		error:function (data){
			alert("请求失败");
		}
	})
}